/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx.controller;

import org.springframework.core.SpringVersion;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;

import com.wf.captcha.GifCaptcha;
import com.wf.captcha.utils.CaptchaUtil;

/**
 * <p>Project: spring2022 - IndexController
 * <p>Powered by webrx On 2022-03-17 08:56:59
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
@RestController
public class IndexController {
    @RequestMapping("hello")
    public String hello() {
        return String.format("Hello SpringMVC %s", SpringVersion.getVersion());
    }

    @RequestMapping("/islogin")
    public boolean isLogin(HttpSession s){
        boolean f = true;
        if(s.getAttribute("user")==null) f = false;
        return true;
    }

    @GetMapping("/cc")
    public void check(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        GifCaptcha c = new GifCaptcha();
        CaptchaUtil.out(c,req,resp);
    }
}

